package com.hzy.quetosys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.hzy.quetosys.dao.PayOutMapper;

import com.hzy.quetosys.entity.PayOut;

import com.hzy.quetosys.service.PayOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PayOutServiceImpl implements PayOutService {
    @Autowired
    private PayOutMapper payOutMapper;
    @Override
    public PageInfo<PayOut> findAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        final List<PayOut> payOuts = payOutMapper.selectAll();
        PageInfo<PayOut> pageInfo=new PageInfo<>(payOuts);
        return pageInfo;
    }

    @Override
    public PageInfo<PayOut> findByKeyword(int pageNum, int pageSize, String keyword) {
        PageHelper.startPage(pageNum,pageSize);
        List<PayOut> payOuts=payOutMapper.selectByKeyword(keyword);
        PageInfo<PayOut> pageInfo=new PageInfo<>(payOuts);
        return pageInfo;
    }

    @Override
    public boolean append(PayOut payOut) {
        return payOutMapper.insert(payOut) > 0;
    }

    @Override
    public PayOut findById(int id) {
        return payOutMapper.selectById(id);
    }

    @Override
    public boolean modify(PayOut payOut) {
        return payOutMapper.updateById(payOut)>0;
    }

    @Override
    public boolean remove(int id) {
        return payOutMapper.deleteById(id) > 0;
    }
}
